'use strict'
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin')

module.exports = {
  css: { extract: false },
  chainWebpack: config => {
    config.plugins.delete('prefetch')
    config.plugins.delete('preload')
  },
  configureWebpack: {
    resolve: {
      fallback: {
        'path': require.resolve('path-browserify')
      }
    },
    plugins: [
      new ParallelUglifyPlugin({
        compress: { // 压缩代码
          dead_code: true, // 移除没被引用的代码
          warnings: false, // 当删除没有用处的代码时，显示警告
          loops: true // 当do、while 、 for循环的判断条件可以确定是，对其进行优化
        },
        except: ['$super', '$', 'exports', 'require'] // 混淆,并排除关键字
      })
    ],
    externals: [
      {
        'vue': 'vue',
        'lodash': 'lodash',
        'element-plus': 'element-plus',
        'codemirror': 'codemirror',
        'vue-router': 'vue-router',
        'vuex': 'vuex',
        'js-cookie': 'js-cookie',
        'nprogress': 'nprogress',
        'axios': 'axios',
        'inputmask': 'inputmask',
        'mockjs': 'mockjs',
        'js-beautify': 'js-beautify',
        'core-js': 'core-js',
        'system': 'system',
        'jsonlint': 'jsonlint',
        'normalize.css': 'normalize.css',
        'xlsx': 'xlsx',
        'qs': 'qs'
      },
      /^codemirror*/,
      /^element-plus*/,
      /^core-js*/,
      /^path-to-regex*/,
      /^file-saver*/,
      /^echarts*/,
      /^mitt*/,
      /^node-sql-parser*/
    ]
  }
}
